from hyrobot.common import STEP, CHECK_POINT, INFO
from lib.webui_permission import *
import pyautogui
import pytest
import time
import json
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By

class c73251:
    name = '添加1条申请记录展示操作之后的申请记录-c73251'  # 测试用例名字
    # 点击的是产品列表第1页的最后一个
    # 记得更改登录用户为超级管理员，英文输入法
    # 初始化方法
    def setup(self):
        STEP(1, '登陆网站')
        driver = open_browser()
        super_login(driver)

    # 清除方法
    def teardown(self):
        driver = get_global_webdriver()
        driver.quit()

    # 测试用例步骤
    def teststeps(self):
        # 获取webdriver对象 对应 已经登录好的浏览器
        driver = get_global_webdriver()
        # driver = webdriver.Firefox()
        extending_button = driver.find_element_by_id("hamburger-container")
        try:
            driver.find_element(By.CLASS_NAME, "el-tooltip")
            extending_button.click()
        except:
            INFO("左侧栏没有隐藏")

        STEP(3, "申请试用")
        commit_apply(driver)
        # time.sleep(3)
        # auto jump,following may need not
        # time.sleep(1)
        # apply_word2 = driver.find_element(By.XPATH,
        #                                   "/html/body/div/div/div[1]/ul/div[2]/a/li/span"
        #                                   )
        # apply_word2.click()
        # time.sleep(1)
        # top_title1 = driver.find_element(By.XPATH,
        #                                  "/html/body/div/div/div[2]/div/div/div[2]/span/span[2]/span[1]/span"
        #                                  ).text
        # CHECK_POINT("上方第2个标题对应", "申请记录" == top_title1)

        STEP(4, "输入一条存在产品名称，项目名称的记录信息点击查询")
        project_name = "xiangmu"
        product_name = "c2021-06-01_11:31:32"
        select_message_list(driver, project_name, product_name)
        got_db_manager_list = get_colum_list(driver, 3)
        got_project_name = get_colum_list(driver,0)
        for i in got_db_manager_list:
            INFO(i)
            CHECK_POINT("db管理员,提示信息是否一致", i == "tom" )
        for j in got_project_name:
            INFO(j)
            CHECK_POINT("项目名称,提示信息是否一致", j == project_name)


